package cn.gok.util;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author: 鸭鸭
 * @ClassName:Generator13
 * @Package:cn.gok.util
 * @Description:
 * @date: 2021/8/8
 * @time: 20:10
 */
public class Generator13 {
    public final static String machineCode13 = "0";
    private final static AtomicInteger sub = new AtomicInteger(0);

    public static long make(){
        StringBuffer sb = new StringBuffer();
        sb.append(machineCode13);
        long timestamp = System.currentTimeMillis()/1000;
        sb.append((timestamp+"").substring(1));
        int subValue = sub.incrementAndGet();
        if(subValue > 999){
            sub.getAndSet(0);
            return make();
        }
        if(subValue<10){
            sb.append("00");
        } else if(subValue<100){
            sb.append("0");
        }
        sb.append(subValue);
        String str=new String(sb);
        long orderNo = Long.parseLong(str);
        return orderNo;
    }
}
